programming4us
           
 
 
Programming

jQuery 1.3 : Sharing a plugin with the world

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/27/2010 3:58:04 PM
Once a plugin is complete, we may want to publish it so that others can benefit from—and possibly improve—the code. We can do this at the official jQuery Plugin Repository at http://plugins.jquery.com/. Here we can log in, or register if we need to, and follow the instructions to describe the plugin and upload a .zip archive of its code. Before this, though, we should make sure the plugin is appropriately polished and prepared for public consumption.

There are a few rules to follow in writing plugins in order to play well with other code. We have covered some of these in passing already, but they are collected again here for convenience.

Naming conventions

All plugin files should be named jQuery.myPlugin.js where myPlugin is the name of the plugin. Within the file, all global functions should be grouped into an object called jQuery.myPlugin, unless there is only one, in which case it may be a function just called jQuery.myPlugin().

Method names are more flexible, but should be kept as unique as possible. If only one method is defined, it should be called jQuery.fn.myPlugin(). If more than one is defined, attempt to prefix each method name with the plugin name to prevent confusion. Avoid short, ambiguous method names such as .load() or .get() that may be confused with methods defined in other plugins.

Use of the $ alias

jQuery plugins may not assume that the $ alias is available. Instead, the full jQuery name must be written out each time.

In longer plugins, many developers find that the lack of the $ shortcut makes code more difficult to read. To combat this, the shortcut can be locally defined for the scope of the plugin by defining and executing a function. The syntax for defining and executing a function at once looks like this:

(function($) {
// Code goes here
})(jQuery);

The wrapping function takes a single parameter, to which we pass the global jQuery object. The parameter is named $, so within the function we can use the $ alias with no conflicts.

Method interfaces

All jQuery methods get called within the context of a jQuery object, so this refers to an object that may refer to one or more DOM elements. All methods must behave correctly regardless of the number of elements actually matched. In general, methods should call this.each() to iterate over the matched elements, operating on each one in turn.

Methods should return the jQuery object to preserve chaining. If the set of matched objects is modified, a new object should be created by calling .pushStack() and this object should be returned instead. If something other than a jQuery object is returned, this must be prominently documented.

If methods take several options, it is preferable to use a map as an argument so that the options are labeled and can be specified in any order. Default values should be defined in a map that can be overridden if necessary.

Method definitions must end in a semicolon (;) character so that code compressors can properly parse the files. In addition, plugins may begin with a semicolon, so that other poorly-coded scripts do not cause conflicts after compression.

Documentation style

In-file documentation should be prepended to each function or method definition in ScriptDoc format. This format is documented at http://www.scriptdoc.org/.
Other -----------------
- Auditing an Existing Site to Identify SEO Problems (part 3) - Fixing an Internal Linking Problem
- Auditing an Existing Site to Identify SEO Problems (part 2) - The Importance of Keyword Reviews
- Auditing an Existing Site to Identify SEO Problems (part 1 - Elements of an Audit
- First Stages of SEO : Defining Your Site’s Information Architecture
- First Stages of SEO : The Major Elements of Planning
- Understanding Your Audience and Finding Your Niche
- Developing an SEO Plan Prior to Site Development
- Setting SEO Goals and Objectives
- jQuery 1.3 : Developing plugins - Adding a selector expression
- jQuery 1.3 : Developing plugins - Method parameters
- The LINQ Set Operators
- iPhone 3D Programming : Vertices and Touch Points - Creating a Wireframe Viewer (part 3)
- iPhone 3D Programming : Vertices and Touch Points - Creating a Wireframe Viewer (part 2)
- iPhone 3D Programming : Vertices and Touch Points - Creating a Wireframe Viewer (part 1)
- iPhone 3D Programming : Vertices and Touch Points - Boosting Performance with Vertex Buffer Objects
- iPhone 3D Programming : Vertices and Touch Points - Saving Memory with Vertex Indexing
- iPhone 3D Programming : Vertices and Touch Points - Reading the Touchscreen
- iPhone 3D Programming : HelloCone with Shaders
- Search Engine Basics : Country-Specific Search Engines
- Search Engine Basics : Vertical Search Engines
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us